[SPARK-40705][SQL] Handle case of using mutable array when converting Row to JSON for Scala 2.13#38154
Closed
Amraneze wants to merge 2 commits intoapache:masterfrom
Closed
[SPARK-40705][SQL] Handle case of using mutable array when converting Row to JSON for Scala 2.13#38154Amraneze wants to merge 2 commits intoapache:masterfrom
Amraneze wants to merge 2 commits intoapache:masterfrom
Conversation
11eba27 to
40e9de4
Compare
|
Can one of the admins verify this patch? |
40e9de4 to
0efc177
Compare
0efc177 to
7075138
Compare
Amraneze
commented
Oct 8, 2022
| StructField("col1", StringType) :: | ||
| StructField("col2", StringType) :: | ||
| StructField("col3", IntegerType) :: Nil) | ||
| StructField("col2", StringType) :: |
Contributor
Author
There was a problem hiding this comment.
Scalafmt formatted the file, should I revert the changes related to formatting the code ?
Member
There was a problem hiding this comment.
Yeah revert all the formatting only changes please
Contributor
Author
There was a problem hiding this comment.
I pushed a new commit with the revert of those changes
srowen
pushed a commit
that referenced
this pull request
Oct 10, 2022
… Row to JSON for Scala 2.13 ### What changes were proposed in this pull request? I encountered an issue using Spark while reading JSON files based on a schema it throws every time an exception related to conversion of types. >Note: This issue can be reproduced only with Scala `2.13`, I'm not having this issue with `2.12` ```` Failed to convert value ArraySeq(1, 2, 3) (class of class scala.collection.mutable.ArraySeq$ofRef}) with the type of ArrayType(StringType,true) to JSON. java.lang.IllegalArgumentException: Failed to convert value ArraySeq(1, 2, 3) (class of class scala.collection.mutable.ArraySeq$ofRef}) with the type of ArrayType(StringType,true) to JSON. ```` If I add ArraySeq to the matching cases, the test that I added passed successfully  With the current code source, the test fails and we have this following error  ### Why are the changes needed? If the person is using Scala 2.13, they can't parse an array. Which means they need to fallback to 2.12 to keep the project functioning ### How was this patch tested? I added a sample unit test for the case, but I can add more if you want to. Closes #38154 from Amraneze/fix/spark_40705. Authored-by: Ait Zeouay Amrane <a.zeouayamran@gmail.com> Signed-off-by: Sean Owen <srowen@gmail.com> (cherry picked from commit 9a97f8c) Signed-off-by: Sean Owen <srowen@gmail.com>
Member
|
Merged to master/3.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
I encountered an issue using Spark while reading JSON files based on a schema it throws every time an exception related to conversion of types.
If I add ArraySeq to the matching cases, the test that I added passed successfully

With the current code source, the test fails and we have this following error

Why are the changes needed?
If the person is using Scala 2.13, they can't parse an array. Which means they need to fallback to 2.12 to keep the project functioning
How was this patch tested?
I added a sample unit test for the case, but I can add more if you want to.